package com.chat.xx.beam.common;

import com.github.pagehelper.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageBeam<T> implements Serializable {
    private static final long serialVersionUID = 4538979293312172658L;
    private Integer currentPage;

    private Integer pageSize;

    private Long totalNum;

    private Integer totalPage;

    private List<T> items;

    public PageBeam(List<T>items ) {
        if (items instanceof Page) {
            Page<T> page = (Page<T>) items;
            this.totalNum = page.getTotal();
            this.totalPage = page.getPages();
            this.currentPage = page.getPageNum();
            this.pageSize = page.getPageSize();
            this.items = page;
        }
    }
}
